package com.glory.cqaospda.adapter;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.glory.cqaospda.R;
import com.glory.cqaospda.bean.SpotCheckInfoBean;

import java.util.List;

import androidx.annotation.Nullable;

public class InspectAdapter extends BaseQuickAdapter<SpotCheckInfoBean.ProCheckList, BaseViewHolder> {
    private List<SpotCheckInfoBean.ProCheckList> datalist;
    private OnItemClickListener mOnItemClickListener;
    private OnItemLongClickListener mOnItemLongClickListener;
    private String eqpID;

    public InspectAdapter(@Nullable List<SpotCheckInfoBean.ProCheckList> data) {
        super(R.layout.adapter_repair, data);
        datalist = data;
    }

    @Override
    protected void convert(BaseViewHolder helper, SpotCheckInfoBean.ProCheckList item) {

        helper.setGone(R.id.tvLongTime,true);
        helper.setText(R.id.tvUserName, item.getOrder_id());
        helper.setText(R.id.tvEquipmentName, item.getLotid());
        helper.setText(R.id.tvPriority, item.getBuyoff_type());
        helper.setText(R.id.tvRepairsType, item.getEquipmentname());
        helper.setText(R.id.tvStart, "编辑");
        helper.getView(R.id.tvStart).setOnClickListener(view -> {
            mOnItemClickListener.onItemClick(item,helper.getAdapterPosition());
        });
        helper.getView(R.id.llItem).setOnLongClickListener(view -> {
            mOnItemLongClickListener.onItemLongClick(item,helper.getAdapterPosition());
            return true;
        });

    }

    public void setOnItemClickListener(OnItemClickListener mOnItemClickListener) {
        this.mOnItemClickListener = mOnItemClickListener;
    }

    public void setOnItemLongClickListener(OnItemLongClickListener mOnItemLongClickListener) {
        this.mOnItemLongClickListener = mOnItemLongClickListener;
    }

    public void setEqpID(String equipmentname) {
        eqpID = equipmentname;
    }

    public interface OnItemClickListener {
        void onItemClick(SpotCheckInfoBean.ProCheckList itemList,int position);
    }
    public interface OnItemLongClickListener {
        void onItemLongClick(SpotCheckInfoBean.ProCheckList itemList,int position);
    }
}
